$(function() {
	admin.userCz.init();
});
Namespace('admin.userCz',{
	init:function() {
		easyui.util.initDatagrid('#datagrid',{
			singleSelect: false,
			selectOnCheck: false,
			checkOnSelect: false,
			onDblClickRow:function() {
			}
		});
	},
	query:function() {
		if(!$('#query-form').form('validate')) return;
		var data=$('#query-form').form('jsonObject');
		$('#datagrid').datagrid('load',data);
	},
	upAgent:function(id) {
		 $.messager.confirm('信息提示', "确定要将此用户升级为村长?", function (success) {
             if (!success) {
                 return;
             }
             $.post(contextPath + '/admin/user/upAgent', {'userId':id}, function (result) {
 	            $('#datagrid').datagrid('loaded');
 	            if (result.code == 0) {
 	               top.showInfo('升级成功');
 	               admin.userCz.query();
 	            } else {
 	                top.showInfo("升级失败，原因："+result.msg);
 	            }
 	        });
    	 });
	},
	reset:function() {//重置按钮
		document.getElementById("communityName").value="";	
		document.getElementById("userName").value="";
		document.getElementById("phone").value="";
	}
});